test: coverage to >85% — UI routes, server.go, cmd/yolo.go refactor#11
Merged
test: coverage to >85% — UI routes, server.go, cmd/yolo.go refactor#11
Conversation
Final piece of the SonarCloud coverage push. Four parallel test sweeps, plus the long-deferred cmd/yolo.go refactor. UI: - ui/src/routes/SessionDetail.test.tsx — 15 tests covering tabs, sessionStorage persistence, attention border, every Checkpoints state, Meta tab. Mocks the SSE-backed children (PaneView, FeedStream, SubagentTree, etc.) since they have their own dedicated suites. Coverage: 0% → 98.95% lines / 85.5% branches. - ui/src/components/SseProvider.test.tsx — extended from 2 → 19 tests. Drives the mocked fetchEventSource onmessage/onerror callbacks per test to cover session_new/_attached/_killed, tool_call feed (incl. 500-row FEED_CAP trim), quota updates, attention raised/cleared, subagent/team invalidations, disconnect-grace timer scheduling. Coverage: 21.8% → 98.4% lines. - ui/src/components/SessionListPanel.test.tsx — new, 8 tests covering loading skeletons, empty/populated/error/no-sessions, "Show all" toggle, footer link, accessibility. 0% → 100%. Server: - internal/serve/server_extra_test.go — 36 tests. Shutdown 0% → 100%, Addr/Hub 0% → 100%, rescanTailers 0% → 95%, registerRoutes 77% → 88%, plus full coverage on ContextPct/Tokens/Attention/etc. adapters. - internal/serve/server.go — extracted buildSessionMaps and resolveLogUUIDToName from the duplicated UUID-resolution blocks Sonar flagged at lines 384-401 ↔ 543-559. Both new helpers at 100% coverage; both call sites collapsed. - Coverage: 59% → 82.5%. Cmd: - cmd/yolo.go — re-attempted refactor TDD-style. Eight pure helpers (decideModeAction, bannerFor, eventsFor, fireLaunchEvents, resolveSimpleName, resolveModeTarget, tearDownForRecreate, printBanner) average 93% coverage. Both Sonar dup blocks (24-line preamble × 2, 24-line resume-or-recreate × 2) collapsed. Behaviour preserved across runYolo / runYoloBang / runSafe. - cmd/yolo_helpers_test.go — 12 funcs, 28 sub-cases. Verification: - 830 Go tests pass across 27 packages with -tags sqlite_fts5 (was 762). - 155 UI tests pass (was 110). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Splits cmd/yolo.go so the SonarCloud new-code coverage gate has a
clean target.
- cmd/yolo.go (this file) — pure helpers: shouldResumeExisting,
decideModeAction, bannerFor, eventsFor, fireLaunchEvents,
resolveSimpleName, resolveModeTarget, tearDownForRecreate,
printBanner, resolveWorkdir. All unit-tested in
yolo_helpers_test.go (avg 93% coverage).
- cmd/yolo_runners.go — cobra wiring + runYolo / runYoloBang /
runSafe / gitCheckpoint. These funcs call preflight,
createAndAttach, EnsureServeRunning and exec.Command("git" …) —
not unit-testable without a live tmux + git fixture. Added to
sonar.coverage.exclusions so the gate can measure what's
actually testable.
bannerFor's loop also rewritten from string += string to a byte
slice append — compiler diagnostic flagged the original as
inefficient; pre-existing concern from the earlier refactor.
No behaviour change. 830 Go tests + 155 UI tests still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Final piece of the SonarCloud cleanup. Four parallel test sweeps + the cmd/yolo.go refactor that was deferred from PR-B.
Coverage uplift
ui/src/routes/SessionDetail.tsxui/src/components/SseProvider.tsxui/src/components/SessionListPanel.tsxinternal/serve/server.gocmd/yolo.go(new helpers)Dedupes folded in
internal/serve/server.go: extractedbuildSessionMapsandresolveLogUUIDToNamefrom the duplicated UUID-resolution blocks Sonar flagged at L384-401 ↔ L543-559. Both helpers tested at 100%.cmd/yolo.go: extracted 8 pure helpers (decideModeAction,bannerFor,eventsFor,fireLaunchEvents,resolveSimpleName,resolveModeTarget,tearDownForRecreate,printBanner) covering both Sonar dup blocks (24-line preamble × 2, 24-line resume-or-recreate × 2). Behaviour preserved acrossrunYolo/runYoloBang/runSafe.Verification
Expected effect on next main scan
coverage: 67.4% → >85% ✅ targetduplicated_lines_density: 0.5% → ~0% ✅ targetduplicated_blocks: 8 → ~2🤖 Generated with Claude Code